/* 
用来操作users集合数据的Model
*/

const moment = require('moment');
const mongoose = require('mongoose');



//定义文档结构
const userSchema = mongoose.Schema({
    username: {
        type: String,
        required: true
    },
    pwd: {
        type: String,
        required: true
    },
    profile: {
        type: String,
        required: true
    },
    create_time: {
        type: String,
        // 默认值: 应该为插入数据的时间
        default:()=>moment().format('YYYY-MM-DD HH:mm:ss')// 函数开始不执行, 插入数据时才执行
    }
}, { versionKey: false })

//创建Model                    //集合名    文档结构名  
const UserModel = mongoose.model('users', userSchema)

//暴露Model
module.exports = UserModel;